var Observer = require('./Observer');
var globalOptions = require('./globalOptions');
var globalState = require('./globalState');
var TextNode = function () {
};
TextNode.prototype = Object.create(Object.prototype, {
    constructor: {
        value: TextNode,
        writable: true,
        configurable: true
    }
});
var _advancedCreate = TextNode._advancedCreate = function (e, t) {
    var i = new TextNode();
    i.__slot = '';
    var n = null;
    globalState.backendExtractedDefault || 'dom' !== globalOptions.documentBackend ? i.__textContent = e : (n = document.createTextNode(e || '')).__wxElement = i;
    i.$$ = i.__domElement = n;
    i.__backendExtracted = globalState.backendExtractedDefault;
    i.__subtreeObserversCount = 0;
    i.parentNode = null;
    i.ownerShadowRoot = t;
    return i;
};
TextNode.create = function (e) {
    return _advancedCreate(e, null);
};
Object.defineProperty(TextNode.prototype, 'textContent', {
    get: function () {
        return this.__domElement ? this.__domElement.textContent : this.__textContent;
    },
    set: function (e) {
        this.__domElement ? this.__domElement.textContent = e : this.__textContent = String(e);
        (this.__textObservers && !this.__textObservers.empty || this.__subtreeObserversCount) && Observer._callObservers(this, '__textObservers', {
            type: 'characterData',
            target: this
        });
    }
});
module.exports = TextNode;
